/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Actors;

import ElementsProperties.Bouncable;
import Model.Case;
import Model.CollisionEvent;

/**
 *
 * @author Snowangelic
 */
public class BouncableActor extends Actor implements Bouncable {

    public void bounce(CollisionEvent e) {
        if(e.getActor()==this){
            if(e.getCollisionType()==CollisionType.Up)
                bounceFromBottom(e.getCase());
            else if(e.getCollisionType()==CollisionType.Down)
                bounceFromTop(e.getCase());
            else if(e.getCollisionType()==CollisionType.Left)
                bounceFromRight(e.getCase());
            else if(e.getCollisionType()==CollisionType.Right)
                bounceFromLeft(e.getCase());

    }

}

    private void bounceFromBottom(Case aCase) {
        setY((aCase.getYIndex()*32)-11);
            setDy(0-getDy());
    }

    private void bounceFromLeft(Case aCase) {
        setX(((aCase.getXIndex()+1)*32)+10);
            setDx(0-getDx());
    }

    private void bounceFromRight(Case aCase) {
        setX(((aCase.getXIndex()*32)-11));
            setDx(0-getDx());
    }

    private void bounceFromTop(Case aCase) {
        setY(((aCase.getYIndex()+1)*32)+10);
           setDy(0-getDy());
    }
}
